package com.jerry.usbserial.util.download

import java.io.File
import java.util.*

/**
 * Created by dugang on 2018/11/16.
 */

data class DownloadInfo(
        var id: Long = 0,
        var url: String = "",
        var savePath: String = "",
        var total: Long = 0,
        var progress: Long = 0,
        var status: Int = DownloadManager.STATUS_PENDING
)

/**
 * DownloadInfo的深度copy
 */
fun DownloadInfo.deepCopy(): DownloadInfo = DownloadInfo().apply {
    id = this@deepCopy.id
    url = this@deepCopy.url
    savePath = this@deepCopy.savePath
    total = this@deepCopy.total
    progress = this@deepCopy.progress
    status = this@deepCopy.status
}

/**
 * 下载监听器
 */
interface OnDownloadListener {
    fun onPending()

    fun onProgress(progress: Long, total: Long)

    fun onCompleted(file: File)

    fun onPaused()

    fun onCanceled()

    fun onFailed()
}
